﻿using Resources.Scripts.Socket.MyChat.Protocol;

namespace Resources.Scripts.Utils
{
    public class MessageFormatSplit
    {
        private string message;

        public string Message { get; set; }

        public MessageFormatSplit(string message)
        {
            this.message = message;
        }

        public MessageFormatSplit()
        {
            
        }


        public ChatChannel GetChatChannel()
        {
            return (ChatChannel)int.Parse(message.Substring(0, 8));
        }

        public User GetSenderUser()
        {
            // return User.FormString(message.Substring(8, 68));
            return User.FormString(message.Substring(9, message.IndexOf("}") - 9));
        }

        public string GetMessage()
        {
            return message.Substring(message.IndexOf("}") + 1);
        }
    }
}